package com.cis467.mrball.parts;

public class TestLevel {

	Level test;
	
	Floor start,key,end;
	
	Button bRed, bBlue, bGreen, bYellow;
	Portal p1Red, p2Red, p1Blue, p2Blue, p1Green, p2Green, p1Yellow, p2Yellow;
	
	public TestLevel(){
		
		test = new Level();
	
		for(int i = 0; i < Level.FLOOR_COLS; i++) {
			for(int j = 0; j < Level.FLOOR_ROWS; j++) {
				test.setFloor(new Floor(i,j,Floor.NORMAL));
			}
		}
		
		for(int i = 0; i < Level.HWALL_COLS; i++) {
			for(int j = 0; j < Level.HWALL_ROWS; j++) {
				test.setHWall(new Wall(i,j,Wall.NONE));
			}
		}
		
		for(int i = 0; i < Level.VWALL_COLS; i++) {
			for(int j = 0; j < Level.VWALL_ROWS; j++) {
				test.setVWall(new Wall(i,j,Wall.NONE));
			}
		}
		
		setSKE();
		
		setRed();
		setBlue();
		setGreen();
		setYellow();
		
		setPits();
		setSlows();
		setFasts();
		
		setHWalls();
		setHLasers();
		
		setVWalls();
		setVLasers();
	}
	
	private void setSKE() {
		test.setStart(new Floor(1, 1, Floor.NORMAL));
		test.setKey(new Floor(11, 8, Floor.NORMAL));
		test.setEnd(new Floor(3, 7, Floor.NORMAL));
		test.end.isVisible = false;
	}
	
	private void setRed() {
		bRed = new Button(0, 0, Floor.NORMAL, Button.RED);
    	p1Red = new Portal(0, 6, Floor.NORMAL, Portal.RED);
    	p2Red = new Portal(9, 0, Floor.NORMAL, Portal.RED);
    	
    	bRed.p1 = p1Red;
    	bRed.p2 = p2Red;
    	
    	p1Red.other = p2Red;
    	p2Red.other = p1Red;
    	
    	bRed.isVisible = true;
    	p1Red.isVisible = false;
    	p2Red.isVisible = false;
    	
    	test.setButton(bRed);
    	test.setPortal(p1Red);
    	test.setPortal(p2Red);
	}
	
	private void setBlue() {
		bBlue = new Button(4, 2, Floor.NORMAL, Button.BLUE);
    	p1Blue = new Portal(11, 0, Floor.NORMAL, Portal.BLUE);
    	p2Blue = new Portal(10, 8, Floor.NORMAL, Portal.BLUE);
    	
    	bBlue.p1 = p1Blue;
    	bBlue.p2 = p2Blue;
    	
    	p1Blue.other = p2Blue;
    	p2Blue.other = p1Blue;
    	
    	bBlue.isVisible = true;
    	p1Blue.isVisible = false;
    	p2Blue.isVisible = false;
    	
    	test.setButton(bBlue);
    	test.setPortal(p1Blue);
    	test.setPortal(p2Blue);
	}
	
	private void setGreen() {
		bGreen = new Button(11, 3, Floor.NORMAL, Button.GREEN);
    	p1Green = new Portal(8, 6, Floor.NORMAL, Portal.GREEN);
    	p2Green = new Portal(3, 8, Floor.NORMAL, Portal.GREEN);
    	
    	bGreen.p1 = p1Green;
    	bGreen.p2 = p2Green;
    	
    	p1Green.other = p2Green;
    	p2Green.other = p1Green;
    	
    	bGreen.isVisible = true;
    	p1Green.isVisible = false;
    	p2Green.isVisible = false;
    	
    	test.setButton(bGreen);
    	test.setPortal(p1Green);
    	test.setPortal(p2Green);
	}
	
	private void setYellow() {
		bYellow = new Button(6, 2, Floor.NORMAL, Button.YELLOW);
    	p1Yellow = new Portal(1, 2, Floor.NORMAL, Portal.YELLOW);
    	p2Yellow = new Portal(11, 6, Floor.NORMAL, Portal.YELLOW);
    	
    	bYellow.p1 = p1Yellow;
    	bYellow.p2 = p2Yellow;
    	
    	p1Yellow.other = p2Yellow;
    	p2Yellow.other = p1Yellow;
    	
    	bYellow.isVisible = true;
    	p1Yellow.isVisible = false;
    	p2Yellow.isVisible = false;
    	
    	test.setButton(bYellow);
    	test.setPortal(p1Yellow);
    	test.setPortal(p2Yellow);
	}
	
	private void setPits(){
		
		test.setFloor(new Floor(0,7,Floor.PIT));
		test.setFloor(new Floor(0,8,Floor.PIT));
		
		test.setFloor(new Floor(2,0,Floor.PIT));
		test.setFloor(new Floor(2,1,Floor.PIT));
		test.setFloor(new Floor(2,2,Floor.PIT));
		test.setFloor(new Floor(2,3,Floor.PIT));
		test.setFloor(new Floor(2,4,Floor.PIT));
		test.setFloor(new Floor(2,5,Floor.PIT));
		
		test.setFloor(new Floor(3,0,Floor.PIT));
		test.setFloor(new Floor(3,4,Floor.PIT));
		test.setFloor(new Floor(3,5,Floor.PIT));
		
		test.setFloor(new Floor(4,0,Floor.PIT));
		
		test.setFloor(new Floor(5,0,Floor.PIT));
		
		test.setFloor(new Floor(6,0,Floor.PIT));
		
		test.setFloor(new Floor(7,0,Floor.PIT));
		test.setFloor(new Floor(7,4,Floor.PIT));
		test.setFloor(new Floor(7,5,Floor.PIT));
		
		test.setFloor(new Floor(8,0,Floor.PIT));
		test.setFloor(new Floor(8,1,Floor.PIT));
		test.setFloor(new Floor(8,2,Floor.PIT));
		test.setFloor(new Floor(8,3,Floor.PIT));
		test.setFloor(new Floor(8,4,Floor.PIT));
		test.setFloor(new Floor(8,5,Floor.PIT));
		
		test.setFloor(new Floor(10,0,Floor.PIT));
		test.setFloor(new Floor(10,1,Floor.PIT));
		test.setFloor(new Floor(10,2,Floor.PIT));
		test.setFloor(new Floor(10,3,Floor.PIT));
		test.setFloor(new Floor(10,4,Floor.PIT));
		test.setFloor(new Floor(10,5,Floor.PIT));
		test.setFloor(new Floor(10,6,Floor.PIT));	
	}
	
	private void setSlows() {
		
		test.setFloor(new Floor(3,1,Floor.SLOW));
		test.setFloor(new Floor(3,2,Floor.SLOW));
		test.setFloor(new Floor(3,3,Floor.SLOW));
		
		test.setFloor(new Floor(4,1,Floor.SLOW));
		test.setFloor(new Floor(4,3,Floor.SLOW));
		test.setFloor(new Floor(4,4,Floor.SLOW));
		test.setFloor(new Floor(4,5,Floor.SLOW));
		
		test.setFloor(new Floor(5,1,Floor.SLOW));
		
		test.setFloor(new Floor(6,1,Floor.SLOW));
		test.setFloor(new Floor(6,3,Floor.SLOW));
		test.setFloor(new Floor(6,4,Floor.SLOW));
		test.setFloor(new Floor(6,5,Floor.SLOW));
		
		test.setFloor(new Floor(7,1,Floor.SLOW));
		test.setFloor(new Floor(7,2,Floor.SLOW));
		test.setFloor(new Floor(7,3,Floor.SLOW));
		
		test.setFloor(new Floor(9,6,Floor.SLOW));
		test.setFloor(new Floor(9,7,Floor.SLOW));
		test.setFloor(new Floor(9,8,Floor.SLOW));	
	}
	
	private void setFasts() {
		
		test.setFloor(new Floor(0,1,Floor.FAST));
		test.setFloor(new Floor(0,2,Floor.FAST));
		test.setFloor(new Floor(0,3,Floor.FAST));
		test.setFloor(new Floor(0,4,Floor.FAST));
		test.setFloor(new Floor(0,5,Floor.FAST));
		
		test.setFloor(new Floor(5,4,Floor.FAST));
		test.setFloor(new Floor(5,5,Floor.FAST));
	}
	
	private void setHWalls() {
		
    	for(int col = 0; col < Level.HWALL_COLS; col++)
    		for(int row = 0; row < Level.HWALL_ROWS; row++)
    			if(row == 0 || row == Level.HWALL_ROWS-1)
    				test.setHWall(new Wall(col,row, Wall.NORMAL));
    			
		
		test.setHWall(new Wall(0,7,Wall.NORMAL));
		
		test.setHWall(new Wall(1,2,Wall.NORMAL));
		test.setHWall(new Wall(1,7,Wall.NORMAL));
		
		test.setHWall(new Wall(2,6,Wall.NORMAL));
		test.setHWall(new Wall(2,7,Wall.NORMAL));
		test.setHWall(new Wall(2,8,Wall.NORMAL));
		
		test.setHWall(new Wall(3,6,Wall.NORMAL));
		test.setHWall(new Wall(3,7,Wall.NORMAL));
		test.setHWall(new Wall(3,8,Wall.NORMAL));
		
		test.setHWall(new Wall(7,6,Wall.NORMAL));
		
		test.setHWall(new Wall(8,6,Wall.NORMAL));
		
		test.setHWall(new Wall(10,7,Wall.NORMAL));
		
		test.setHWall(new Wall(11,7,Wall.NORMAL));
	}
	
	private void setHLasers() {
		
		test.setHWall(new Wall(2,8,Wall.LASER));
	}
    		
    private void setVWalls() {
    	
    	for(int col = 0; col < Level.VWALL_COLS; col++)
    		for(int row = 0; row < Level.VWALL_ROWS; row++)
    			if(col == 0 || col == Level.VWALL_COLS-1)
    				test.setVWall(new Wall(col,row, Wall.NORMAL));
    	
    	
    	
    	test.setVWall(new Wall(1,1,Wall.NORMAL));
    	test.setVWall(new Wall(1,2,Wall.NORMAL));
    	test.setVWall(new Wall(1,3,Wall.NORMAL));
    	test.setVWall(new Wall(1,4,Wall.NORMAL));
    	test.setVWall(new Wall(1,5,Wall.NORMAL));
    	test.setVWall(new Wall(1,6,Wall.NORMAL));
    	
    	test.setVWall(new Wall(2,0,Wall.NORMAL));
    	test.setVWall(new Wall(2,1,Wall.NORMAL));
    	test.setVWall(new Wall(2,2,Wall.NORMAL));
    	test.setVWall(new Wall(2,3,Wall.NORMAL));
    	test.setVWall(new Wall(2,4,Wall.NORMAL));
    	test.setVWall(new Wall(2,5,Wall.NORMAL));
    	
    	test.setVWall(new Wall(4,7,Wall.NORMAL));
    	test.setVWall(new Wall(4,8,Wall.NORMAL));
    	
    	test.setVWall(new Wall(9,0,Wall.NORMAL));
    	test.setVWall(new Wall(9,1,Wall.NORMAL));
    	test.setVWall(new Wall(9,2,Wall.NORMAL));
    	test.setVWall(new Wall(9,3,Wall.NORMAL));
    	test.setVWall(new Wall(9,4,Wall.NORMAL));
    	test.setVWall(new Wall(9,5,Wall.NORMAL));
    	
    	test.setVWall(new Wall(10,7,Wall.NORMAL));
    	test.setVWall(new Wall(10,8,Wall.NORMAL));
    	
    	test.setVWall(new Wall(11,0,Wall.NORMAL));
    	test.setVWall(new Wall(11,1,Wall.NORMAL));
    	test.setVWall(new Wall(11,2,Wall.NORMAL));
    	test.setVWall(new Wall(11,3,Wall.NORMAL));
    	test.setVWall(new Wall(11,4,Wall.NORMAL));
    	test.setVWall(new Wall(11,5,Wall.NORMAL));
    	test.setVWall(new Wall(11,6,Wall.NORMAL));
    	test.setVWall(new Wall(11,8,Wall.NORMAL));
    	
    }
    
    private void setVLasers() {
    	
    	//test.setVWall(new Wall(4,8,Wall.LASER));
    }
	
	
	public Level getLevel() {
		return test;
	}
	
	public String toString(){
		return test.toString();
	}
	
}
